import java.io.*;
import java.net.Socket;

//客户端：数据来自于文件 D:\JavaLearn\idea\Code\JavaSE_Code\MyNet\src\tmp\data1.txt ，直到读入的数据是886, 发送数据结束
public class TCP_Demo2_client_plus {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.191.1", 10001);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\JavaLearn\\idea\\Code\\JavaSE_Code\\MyNet\\src\\tmp\\data1.txt")));
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        String line;
        while((line = bufferedReader.readLine()) != null){
            if(line.equals("886"))
                break;
            bufferedWriter.write(line);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }
        socket.close();
        bufferedReader.close();
        bufferedWriter.close();
    }
}
